home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vb_term2 / tty.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  4.7 KB  |  171 lines

  1. VERSION 2.00
  2. Begin Form TTY 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   0  'None
  5.    Caption         =   "Terminal"
  6.    ClientHeight    =   405
  7.    ClientLeft      =   1050
  8.    ClientTop       =   2160
  9.    ClientWidth     =   4365
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Courier"
  13.    FontSize        =   9.75
  14.    FontStrikethru  =   0   'False
  15.    FontTransparent =   0   'False
  16.    FontUnderline   =   0   'False
  17.    ForeColor       =   &H00000000&
  18.    Height          =   1095
  19.    Icon            =   TTY.FRX:0000
  20.    Left            =   990
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   27
  24.    ScaleMode       =   3  'Pixel
  25.    ScaleWidth      =   291
  26.    Top             =   1530
  27.    Width           =   4485
  28.    Begin Menu file 
  29.       Caption         =   "&File"
  30.       Begin Menu mcexit 
  31.          Caption         =   "&Exit"
  32.          Shortcut        =   ^X
  33.       End
  34.    End
  35.    Begin Menu settings 
  36.       Caption         =   "&Settings"
  37.       Begin Menu comparams 
  38.          Caption         =   "&Com Params"
  39.       End
  40.    End
  41.    Begin Menu transfers 
  42.       Caption         =   "&Transfers"
  43.       Begin Menu capture 
  44.          Caption         =   "&Capture to file ..."
  45.          Shortcut        =   ^C
  46.       End
  47.    End
  48. Sub capture_Click ()
  49.     If (FlagCapture = 0) Then
  50.         opencapture.Show 1
  51.     Else
  52.         Close #FlagCapture
  53.         FlagCapture = 0
  54.         capture.caption = "Capture to file ..."
  55.     End If
  56. End Sub
  57. Sub CloseCom ()
  58.     Dim x As Integer
  59.     x = SerialClose()
  60.     If (x < 0) Then
  61.         MsgBox "Close Error"
  62.     Else
  63.         MsgBox "Closed"
  64.     End If
  65. End Sub
  66. Sub comparams_Click ()
  67.     Call ConfigCom
  68. End Sub
  69. Sub ConfigCom ()
  70.     Call hide_cursor
  71.     mousepointer = 11
  72.     TConfigChanged = 0
  73.     config.Show 1
  74.     x% = DoEvents()         ' Force Screen Update
  75.     If (TConfigChanged <> 0) Then
  76.         x% = SerialClose()
  77.         x% = SerialOpen(TPort)
  78.         x% = SerialConfig(TBaud, TWord, TParity)
  79.     End If
  80.     mousepointer = 0
  81.     Call disp_cursor
  82. End Sub
  83. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  84.     '------------------------------------------------------------------------
  85.     '   Form_KeyDown
  86.     '
  87.     '   intercepts keys which do not generate an ANSI code, such as the
  88.     '   function and cursor movement keys, and translates them into VT100
  89.     '   style kepresses which are transmitted to the Form_Keypress()
  90.     '   event, which deals with transmitting keystrokes.  It could
  91.     '   alternatively transmit keystrokes directly.
  92.     '------------------------------------------------------------------------
  93.     buf$ = ""
  94.     Select Case KeyCode
  95.         Case KEY_LEFT
  96.             buf$ = "[D"
  97. '        Case KEY_END
  98. '            buf$ = ""
  99.         Case KEY_HOME
  100.             buf$ = "[H"
  101.         Case KEY_UP
  102.             buf$ = "[A"
  103.         Case KEY_RIGHT
  104.             buf$ = "[C"
  105.         Case KEY_DOWN
  106.             buf$ = "[B"
  107. '        Case KEY_INSERT
  108. '            buf$ = ""
  109. '        Case KEY_DELETE
  110. '            buf$ = ""
  111.         Case Else
  112.             Exit Sub
  113.     End Select
  114.     buf$ = Chr$(27) + buf$
  115.     r% = SerialWrite(buf$)
  116. End Sub
  117. Sub form_KeyPress (KeyAscii As Integer)
  118.     r% = SerialWrite(Chr$(KeyAscii))
  119. End Sub
  120. Sub Form_Load ()
  121.     mousepointer = 11
  122.     tty.scalemode = 1
  123.     tty.height = (tty.height - tty.scaleheight) + 24.25 * tty.TextHeight("M")
  124.     tty.width = (tty.width - tty.scalewidth) + 80 * tty.TextWidth("M")
  125.     tty.top = 0
  126.     tty.left = (screen.width - tty.width) / 2
  127.     tty.scalemode = 3
  128.     tty.Show
  129.     Call term_init
  130.     config.Show 1
  131.     r% = SerialOpen(TPort)
  132.     If (r% <> 0) Then
  133.         MsgBox "Unable to open port", 16, "VBTERM"
  134.         End
  135.     End If
  136.     r% = SerialConfig(TBaud, TWord, TParity)
  137.     If (r% <> 0) Then
  138.         MsgBox "Unable to configure port", 16, "VBTERM"
  139.         End
  140.     End If
  141.     FlagCapture = 0
  142.     mousepointer = 0
  143.     Call ReceiveLoop
  144. End Sub
  145. Sub Form_Paint ()
  146.     Call RedrawScreen
  147. End Sub
  148. Sub Form_Unload (Cancel As Integer)
  149.     i% = SerialClose()
  150.     If (FlagCapture <> 0) Then Close #FlagCapture
  151.     End
  152. End Sub
  153. Sub mcexit_Click ()
  154.     Form_Unload (i%)
  155. End Sub
  156. Sub ReceiveLoop ()
  157.     Dim b As String
  158.     Dim ln As Integer
  159.     b = Space$(128)
  160. ComPollLoop:
  161.         ln = SerialRead(b, 128)
  162.         If ln <> 0 Then
  163.             Call term_put(b, ln)
  164.             If (FlagCapture <> 0) Then Print #FlagCapture, Left$(b, ln);
  165.         Else
  166.             Call disp_cursor
  167.         End If
  168.         x% = DoEvents()
  169.     GoTo ComPollLoop
  170. End Sub
  171.